# Step 1: Build the frontend code
FROM node:22.17.1-slim as builder
WORKDIR /app
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ .
# Run frontend unit tests and build
RUN npm test && npm run build:prod

# Step 2: Serve the frontend (using Nginx)
FROM nginx:alpine
# Copy build results from builder stage to Nginx
COPY --from=builder /app/dist /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]